<?php include "../../layout/header.php"; ?>
<?php require_once('../basicInfo/user.php');?>
<?php include "../../layout/navleft.php"; ?>
<div id="content_small"><div class="container_brown">
<script type="text/javascript" src="<?php echo($siteroot);?>js/shop/cartControl.js"></script>
<script type="text/javascript" src="<?php echo($siteroot);?>js/shop/search.js"></script>
<link rel="stylesheet" href="<?php echo($siteroot);?>css/shop.css" type="text/css" />
<font face="Verdana" color = brown size = 2.5px> Store</font>

<?php include "../../db/dbconnect.php";?>

<br>
<div class="main_shop_head">Welcome to the Item Shop!</div>
<br>
<div class="main_shop_head">
	<a href="<?php echo($siteroot);?>includes/shop/ItemShop.php">
	<img src="<?php echo($siteroot);?>images/shop/enter_button.gif"></a>
</div>

<br><br>
<div class="main_shop_div">
    <table id="new_arrival_table" class="main_shop_table">
        <thead>
        <tr>
            <th  width=50% colspan ="5">New Arrivals</th>
        </tr>
      </thead>

<?php

$query = "SELECT * FROM item ORDER BY item_id DESC";
$result = mysql_query($query);
$queryM = $query." LIMIT 0, 5";
$result = mysql_query($queryM);
$img_tmp = "";
$name_tmp = "";
$buy_tmp = "";

	while($row = mysql_fetch_array($result))
    {
        $name = $row['name'];
        $img = $siteroot.'images/shop/'.$row['file'];
        $price = $row['price_buy'];
        $id = $row['item_id'];
        $img_tmp .= "<td class=\"image_td\"><img class=\"item_image\" src=\"$img\"></td>";
        $name_tmp .= "<td>$name</td>";
        if(isset($_SESSION['logged_in'])){
	        $buy_tmp .= "<td><img src=\"{$siteroot}images/shop/dot.gif\" /> $price
	        <br><input type=\"image\" src=\"{$siteroot}images/shop/buy.gif\" onclick=\"addToCart($id)\"></td>";
        }else{
        	$buy_tmp .= "<td><img src=\"{$siteroot}images/shop/dot.gif\" /> $price<br></td>";
        }
        
    }
    echo "<tr>".$img_tmp."</tr>";
    echo "<tr>".$name_tmp."</tr>";
    echo "<tr>".$buy_tmp."</tr>";
?>
        <!--</tr>-->
    </table>
</div>
<p></p>
<!--</form>-->
<br><br>


<div class="main_shop_div">
    <table id="recommend_table" class ="main_shop_table">
        <thead>
        <tr>
            <th  width=50% colspan ="5">Recommended Items</th>
        </tr>
      </thead>
      <!--<tr>-->

<?php

$query = "SELECT * FROM item ORDER BY price_sell";
$result = mysql_query($query);
$queryM = $query." LIMIT 0, 5";
$result = mysql_query($queryM);
$img_tmp = "";
$name_tmp = "";
$buy_tmp = "";

      while($row = mysql_fetch_array($result))
      {
          $name = $row['name'];
          $img = $siteroot.'images/shop/'.$row['file'];
          $price = $row['price_buy'];
          $id = $row['item_id'];
          $img_tmp .= "<td class=\"image_td\"><img class=\"item_image\" src=\"$img\"></td>";
          $name_tmp .= "<td>$name</td>";
          if(isset($_SESSION['logged_in'])){
	          $buy_tmp .= "<td><img src=\"{$siteroot}images/shop/dot.gif\" /> $price
	             <br><input type=\"image\" src=\"{$siteroot}images/shop/buy.gif\" onclick=\"addToCart($id)\"></td>";
          }else{
          	  $buy_tmp .= "<td><img src=\"{$siteroot}images/shop/dot.gif\" /> $price<br></td>";
          }
      }
      echo "<tr>".$img_tmp."</tr>";
      echo "<tr>".$name_tmp."</tr>";
      echo "<tr>".$buy_tmp."</tr>";
?>
    </table>
</div>
<br>

</div></div>
<?php include "simpleShoppingCart.php"; ?>
<?php include "inventory.php";?>
<?php include "../../layout/footer.php"; ?>